package classes.view.component 
{
	import classes.controller.EDataObject;
	
	import com.carlcalderon.arthropod.Debug;
	import com.greensock.TweenMax;
	import com.greensock.easing.Quart;
	
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	import flash.events.MouseEvent;
	import flash.external.ExternalInterface;
	import flash.text.TextField;
	

	public class PopupGradeItem extends Sprite
	{
		private var _score_text:TextField;
		private var _subject:TextField;
		private var _scoreMC:MovieClip;
		private var _avgMC:MovieClip;
		
		public function PopupGradeItem() 
		{
			super();
			setLayOut();
		}
		
		private function setLayOut():void
		{
			this._score_text    = this.getChildByName('score_txt')	as TextField;
			this._scoreMC	    = this.getChildByName('score_mc')	as MovieClip;
			this._avgMC		    = this.getChildByName('avg_mc')		as MovieClip;
			this._subject		= this.getChildByName('text_title')	as TextField;
		}
		
		public function data_init($data:Object, $num:int):void
		{
			_score_text.text = $data.totalScore;
			_subject.text	 = $data.sb_name;
			
			var a:Number = Number($data.nowRank) / Number($data.totalRank);
			
			
			var t:*;
			var b:Number;
			
			if(a >=0.5){
				t = _avgMC.main_mc;
				
				if(a <=0.75){
					b = 55*1;
				}else{
					b = 55*2;
				}
			}else if(a==0.5){
				t = _scoreMC.main_mc;
				
				b = 1;
			}else{
				t = _scoreMC.main_mc;
				if(a <=0.25){
					b = -55*2;
				}else{
					b = -55*1;
				}
				
			}
			
			TweenMax.to(t, .6, { y:b, delay:$num / 4, ease:Quart.easeInOut} );
			t.score_txt.text = $data.nowRank;
			t.score2_txt.text = $data.varyRank;
		}
	}

}